#include "sys.h"

unsigned char code smg[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff,0xbf};
u8 NixieBuff[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
u8 smg1,smg2,smg3,smg4,smg5,smg6,smg7,smg8;


void Nixie_Scan()
{
	static u8 index;
	
	P0 = 0xff;
	hc138(7);
	hc138(0);
	
	P0 = 0x01 << index;
	hc138(6);
	hc138(0);
	
	P0 = NixieBuff[index];
	hc138(7);
	hc138(0);
	P0 = 0xff;
	
	index++;
	index &= 0x07;
}


void Nixie_Show()
{
	NixieBuff[0] = smg[smg1];
	NixieBuff[1] = smg[smg2];
	NixieBuff[2] = smg[smg3];
	NixieBuff[3] = smg[smg4];
	NixieBuff[4] = smg[smg5];
	NixieBuff[5] = smg[smg6];
	NixieBuff[6] = smg[smg7];
	NixieBuff[7] = smg[smg8];
}

void showMode0()
{
	smg1 = time[0]/10;
	smg2 = time[0]%10;
	
	smg3 =  11;
	smg4 = time[1]/10;
	smg5 = time[1]%10;
	smg6 = 10;
	smg7 = RelaworkVal/10;
	smg8 = RelaworkVal%10;
}

void showMode1()
{
	smg1 = 11;
	smg2 = 11;
	smg3 = smg4 = smg5 = smg6 = 10;
	smg7 = workVal/10;
	smg8 = workVal%10;
}

void show()
{
	if(showMode)
		showMode1();
	else
		showMode0();
}